# Maintainer: Danilo Luvizotto <danilo.luvizotto@gmail.com>
# Contributor: Wieland Hoffmann <the_mineo@web.de>
# Contributor: G_Syme <demichan(at)mail(dot)upb(dot)de>
pkgname=p910nd
pkgver=0.95
pkgrel=7
pkgdesc="A small printer daemon intended for diskless workstations that passes jobs directly to the printer"
arch=('i686' 'x86_64' 'armv5' 'armv5h' 'armv6' 'armv6h' 'armv7' 'armv7h')
url="http://p910nd.sourceforge.net"
license=('GPL2')
backup=('etc/conf.d/p910nd')
options=('emptydirs')
source=(http://downloads.sf.net/$pkgname/$pkgname-$pkgver.tar.bz2 \
        $pkgname.service \
        $pkgname.conf)

CONFIGDIR=/etc/conf.d
INITSCRIPT=""
SCRIPTDIR=""

build() {
  cd $srcdir/$pkgname-$pkgver
  sed -e "s|/var/lock/subsys|/var/lock/$pkgname|" -i $pkgname.c
  sed -e 's|$(INSTALL) $(INITSCRIPT) $(DESTDIR)$(SCRIPTDIR)/$(PROG)||' -i Makefile
  make CONFIGDIR=$CONFIGDIR INITSCRIPT=$INITSCRIPT SCRIPTDIR=$SCRIPTDIR
  sed -e 's|P910ND_OPTS=""|P910ND_OPTS="-f /dev/usb/lp0"|' -i $pkgname.conf
}

package() {
  cd $srcdir/$pkgname-$pkgver
  make CONFIGDIR=$CONFIGDIR INITSCRIPT=$INITSCRIPT SCRIPTDIR=$SCRIPTDIR DESTDIR=$pkgdir install
  install -d -m755 $pkgdir/var/lock/$pkgname
  install -d -m755 $pkgdir/usr/lib/systemd/system
  install -d -m755 $pkgdir/usr/lib/tmpfiles.d
  install -m644 $srcdir/$pkgname.service $pkgdir/usr/lib/systemd/system/$pkgname.service
  install -m644 $srcdir/$pkgname.conf $pkgdir/usr/lib/tmpfiles.d/$pkgname.conf
  chmod 1777 $pkgdir/var/lock
}

md5sums=('c7ac6afdf7730ac8387a8e87198d4491'
         'e37030a69b7bf302cfb23d88e25ebbdf'
         'ea1db6d612058532c525efedd54990f2')
